//-------------------------------------------------------------------
//	Copyright (c) 2010-2012 Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_LOG_FILE_OUTPUT_H
#define _UX_LOG_FILE_OUTPUT_H

#include "CLogger.h"
#include "../FileSys/CFile.h"

namespace Engine
{
namespace CoreSystems
{

	//
	// Txt Log File Output
	//

	class _EXPORT_ CTxtLogOutput : public ILogOutput, public CEngBaseObject
	{
	private:
		CFile			_cFile;
		bool			_bOpen;
		
	private:
		void _AddPrefix(string &str, e_log_msg::type ePrefix);
		void _Open(const char *pFileName);
		void _Close();
		void _Flush(const string &s);

	public:
		CTxtLogOutput(const char *pFileName);
		~CTxtLogOutput();

		bool IsOpen() const		{ return _bOpen; }

		// ILogOutput //
		virtual void Write(const char *pMsg, e_log_msg::type eType, const char *pSrcFile, uint uLine);
		virtual void NewLine();
		virtual void Free();
		
		// CEngBaseObject //
		virtual void Release();
	};



	//
	// Html Log File Output
	//

	class _EXPORT_ CHtmlLogOutput : public ILogOutput, public CEngBaseObject
	{
	private:
		CFile			_cFile;
		atomic_uint32	_uCurColor;
		bool			_bOpen;
		
	private:
		void _SetColor(uint uColor, string &str);
		void _Open(const char *pFileName);
		void _Close();
		void _Flush(const string &s);

	public:
		CHtmlLogOutput(const char *pFileName);
		~CHtmlLogOutput();

		bool IsOpen() const		{ return _bOpen; }

		// ILogOutput //
		virtual void Write(const char *pMsg, e_log_msg::type eType, const char *pSrcFile, uint uLine);
		virtual void NewLine();
		virtual void Free();
		
		// CEngBaseObject //
		virtual void Release();
	};

//-------------------------------------------------------------------

}	// CoreSystems
}	// Engine

#endif	// _UX_LOG_FILE_OUTPUT_H